package cn.neusoft.controller;

import cn.neusoft.pojo.Emp;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Controller
public class HelloController {

    @ResponseBody  //响应数据为JSON
    @RequestMapping("/hello")   //配置请求路径相关信息
    public String sayHello(){
        System.out.println("-----------HelloController=========sayHello------------------");
        return "hello springmvc";
    }

    @ResponseBody
    @RequestMapping("/getArr")
    public Object[] getArray(){
        Object[] array = Arrays.asList("张三", "李四", "王五").toArray();
        return array;
    }


    @ResponseBody
    @RequestMapping("/getEmpList")
    public List<Emp> getList(){
        Emp emp1 = new Emp(1103, "张三", 23, new Date(), 2222.9);
        Emp emp2 = new Emp(1103, "李四", 23, new Date(), 3333.9);
        Emp emp3 = new Emp(1103, "王五", 23, new Date(), 4444.9);
        Emp emp4 = new Emp(1103, "赵六", 23, new Date(), 5555.9);
        Emp emp5 = new Emp(1103, "钱七", 23, new Date(), 6666.9);

        List<Emp> emps = Arrays.asList(emp1, emp2, emp3, emp4, emp5);
        return emps;
    }
}
